package com.etc.medical.feign;

import com.etc.common.utils.Result;
import com.etc.drug.entity.OutBound;
import com.etc.drug.entity.Prescription;
import com.etc.medical.client.PrescriptionClient;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 29322
 */
@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/ps")
public class PrescriptionFeign {

    @Resource
    private PrescriptionClient prescriptionClient;

    /**
     * 查询职位为药剂师的所有在职医生
     */
    @RequestMapping("/queryDrugDoc")
    public Result queryDrugDoc() {
        return prescriptionClient.queryDrugDoc();
    }
    /**
     * 根据抓药人id查询处方信息
     */
    @RequestMapping("/queryByDocId")
    public Result queryByDocId(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize,
                               @RequestParam("docId") String docId) {
        return prescriptionClient.queryByDocId(pageNum, pageSize, docId);
    }

    /**
     * 根据门诊id查询病人处方列表
     */
    @RequestMapping("/queryByOsId")
    public Result queryByOsId(@RequestParam("osId") String osId) {
        return prescriptionClient.queryByOsId(osId);
    }

    /**
     * 新增处方
     */
    @RequestMapping(value = "/insert", method = RequestMethod.POST)
    public Result insert(@RequestParam("patientId") String patientId,@RequestParam("osId") String osId,
                         @RequestParam("prescriptionUsage") String prescriptionUsage,
                         @RequestParam("auditorId") String auditorId,
                         @RequestBody List<OutBound> outBoundList,
                         @RequestParam("operatorId") String operatorId) {
        return prescriptionClient.insert(patientId,osId,prescriptionUsage,auditorId,outBoundList,operatorId);
    }

    /**
     * 修改处方
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Result update(@RequestBody Prescription prescription, @RequestParam("operatorId") String operatorId) {
        return prescriptionClient.update(prescription, operatorId);
    }

    /**
     * 药剂师审核处方未通过
     */
    @RequestMapping(value = "/breakDrug", method = RequestMethod.POST)
    public Result breakDrug(@RequestParam("prescriptionId") String prescriptionId,
                            @RequestParam("operatorId") String operatorId) {
        return prescriptionClient.breakDrug(prescriptionId, operatorId);
    }

}
